<script setup>
import { ElConfigProvider } from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

// 获取当前路由
const route = useRoute()

// 定义全屏页面路径
const fullscreenRoutes = [
  // '/search-engine/home',  // 多维检索中心 - 改为与侧边栏共存
  // '/search-engine/list',  // 结果处理工作区 - 改为与侧边栏共存
  // '/search-engine/detail',  // 知识图谱透视页面 - 改为与侧边栏共存
  // '/scenario-simulation/home',  // 剧情编辑工作台 - 改为与侧边栏共存
  // '/scenario-simulation/list',  // 仿真推演控制台 - 改为与侧边栏共存
  // '/scenario-simulation/detail',  // 数据集工厂 - 改为与侧边栏共存
  // '/system-management/home',  // 流程监控中心 - 改为与侧边栏共存
  // '/system-management/list',  // 安全审计中心 - 改为与侧边栏共存
  // '/system-management/detail'  // 数据目录导航器 - 改为与侧边栏共存
  // '/visualization/home',  // 电磁态势总览 - 改为与侧边栏共存
  // '/visualization/list',  // 信号分析实验室 - 改为与侧边栏共存
  // '/visualization/detail'  // 威胁评估驾驶舱 - 改为与侧边栏共存
]

// 判断是否显示侧边栏
const showSidebar = computed(() => {
  return !fullscreenRoutes.includes(route.path)
})
</script>

<template>
  <el-config-provider :locale="zhCn">
    <div id="app">
      <!-- 只在非全屏页面显示侧边栏 -->
      <Sidebar v-if="showSidebar" @sidebar-toggle="handleSidebarToggle"/>
      <div class="main-content" :class="{ 'fullscreen': !showSidebar, 'sidebar-collapsed': isSidebarCollapsed }">
        <div class="main-content content-child" :class="{'sidebar-collapsed': isSidebarCollapsed}">
          <router-view/>
        </div>
      </div>
    </div>
  </el-config-provider>
</template>

<script>
import Sidebar from './components/Sidebar.vue'

export default {
  components: { Sidebar },
  data () {
    return {
      isSidebarCollapsed: false
    }
  },
  methods: {
    handleSidebarToggle (collapsed) {
      this.isSidebarCollapsed = collapsed
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.content-child{
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.main-content {
  flex: 1;
  //overflow: hidden;
}

.main-content.fullscreen {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}
</style>

